# Contributor: Alexander Georgievskiy <galeksandrp@gmail.com>

_realname=polipo
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.1
pkgrel=1
pkgdesc='The Polipo caching HTTP proxy (mingw-w64)'
arch=('any')
license=('MIT')
url="https://github.com/jech/${_realname}"
source=("${url}/archive/${_realname}-${pkgver}.tar.gz"
        '416e59f75934cd1c42fcf043f118b2d1a4e4e8d4.patch'
        'a532fc1ceee6cb6ecb5dd04cb360a757bb037dfe.patch'
        'd2df61dcde8079e1f7e5f8bcffefefa10277540f.patch'
        'fix-install-folders.patch')
sha256sums=('de0afeeaa47df776420e59b69e9a78f68e8a7bc4a46b739772e1d91119ed2405'
            '4e7960d27948b2e351d238e923110d796892d97ed52f4eb62c156fd7873b0bd2'
            '4d293afc404048e75cabf845e146757efafe23db7b2a627d693a10a438e7f1c8'
            '89d9bc2ffb596a7a18f50e22373cd77f29fc6086d718ddce156c16c8d8eb805b'
            'cf6dd8cc8edfd3130bedbbb3d334005370386955040cd993191ac6a4ae9d6a0e')

prepare() {
  cd ${srcdir}/${_realname}-${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/416e59f75934cd1c42fcf043f118b2d1a4e4e8d4.patch
  patch -p1 -i ${srcdir}/a532fc1ceee6cb6ecb5dd04cb360a757bb037dfe.patch
  patch -p1 -i ${srcdir}/d2df61dcde8079e1f7e5f8bcffefefa10277540f.patch
  patch -p1 -i ${srcdir}/fix-install-folders.patch
}

build() {
  cd ${srcdir}/${_realname}-${_realname}-${pkgver}

  make EXE=.exe LDLIBS=-lwsock32
}

package() {
  cd ${srcdir}/${_realname}-${_realname}-${pkgver}

  make PREFIX=${pkgdir}${MINGW_PREFIX} install
}
